import React, { useState, useEffect } from 'react';

import { NavBar, Icon, Grid } from 'antd-mobile';

import { createForm } from 'rc-form'

import './helpDetails.scss';

import { GetParentKnowHtml, GetTutorKnowHtml } from "@/api/login.js"; // login api

function HelpDetails (props) {
    let [knowHtml, setKnowHtml] = useState("");

    // 注册须知
    function axiosGetKnowHtml () {
        console.log(props)
        if (sessionStorage.getItem('roleVal') == 'TUTOR') {
            GetTutorKnowHtml().then(res => {
                if (res.code == "000000") {
                    console.log('res ----->>>', res)
                    setKnowHtml(res.responseData)
                }
            })
                .catch((err) => {
                    console.log('err ----->>>', err)
                })
        } else if (sessionStorage.getItem('roleVal') == 'PARENT') {
            GetParentKnowHtml().then(res => {
                if (res.code == "000000") {
                    console.log('res ----->>>', res)
                    setKnowHtml(res.responseData)
                }
            })
                .catch((err) => {
                    console.log('err ----->>>', err)
                })
        }


    }

    useEffect(() => {
        axiosGetKnowHtml()
    }, [])


    return (
        <div className="helpDetails">
            <div className="page-title helpDetails-tit">
                <NavBar
                    mode="light"
                    icon={<Icon type="left" />}
                    onLeftClick={() => {
                        props.history.goBack()
                    }}
                >
                    测前学习
                </NavBar>
            </div>
            <div className="page-content helpDetails-con" dangerouslySetInnerHTML={{ __html: knowHtml }}>

            </div>
        </div>
    );
}

HelpDetails = createForm()(HelpDetails);

export default HelpDetails;